package cn.gpdi.verification;

import cn.gpdi.framework.dao.CommDAO;
import cn.gpdi.framework.iface.IVerification;
import cn.gpdi.framework.util.CommUtil;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

/**
 * Created by 司徒鑫(QQ:156845600) on 2018/7/20.
 */
public class BroadcastVerify implements IVerification {

    @Override
    public Object doVerification(Object obj) throws Exception {
        Map param=(Map) obj;
        if(param.get("a_boradcast")==null||"0".equals(param.get("a_boradcast").toString())||"".equals(param.get("a_boradcast").toString())){
            return true;
        }
        CommDAO commDAO= (CommDAO) CommUtil.getBean("commDAO");

        //判断已存在轮播图
        if(commDAO.querySQL("select 1 from bs_article where a_boradcast='1'").size()>4){
            throw new Exception("轮播图最多只能设置4张");
        }
        return true;
    }
}
